/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ecc;

import java.util.ArrayList;

/**
 *
 * @author msimplicio
 */
public class ByteBuffer extends ArrayList<byte[]>{

	public byte[] toByteArray(){
		int totalLen = 0;
		for (Object obj : this) {
			totalLen += ((byte[]) obj).length;
		}

		byte[] bytes = new byte[totalLen];
		int off = 0;
		for (Object obj : this) {
			byte[] b = (byte[]) obj;
			System.arraycopy(b, 0, bytes, off, b.length);
			off += b.length;
		}

		return bytes;
	}

}
